package com.gbcom.autocompile;

import java.io.IOException;

import javax.mail.MessagingException;
import javax.mail.internet.AddressException;

import org.apache.log4j.Logger;

import com.gbcom.autocompile.mail.MailNotify;
import com.gbcom.autocompile.prop.SysProperies;
import com.gbcom.op.util.StringUtils;

public class Test {
	private static final Logger logger = Logger.getLogger(Test.class);

	public static void main(String args[]) throws IOException,
			InterruptedException, AddressException, MessagingException {

		// cmd();

		mail();

	}

	private static void cmd() throws IOException, InterruptedException {
		String cmd = "cmd /C D:/test.bat";
		Process ps = Runtime.getRuntime().exec(cmd);
		ps.waitFor();

	}

	public static void mail() throws AddressException, MessagingException {
		String[] toMailers = new String[] { "sunyanzheng@hyxell.com" };
		logger.info(" the BatRunJob [step --3--]~~ ;; Send-mail >> sender:"
				+ SysProperies.getValue("mail.from.addr") + ";to:"
				+ StringUtils.arrayToDelimitedString(toMailers, "|"));

		MailNotify.sendSmtpEmail(
				SysProperies.getValue("mail.from.addr"),
				SysProperies.getValue("mail.from.user"),
				"Sunday" + SysProperies.getValue("mail.from.pwd"),
				SysProperies.getValue("mail.server"),
				toMailers,
				"版本构建",
				"--    每日构建      --  time [ sss]  --- </br>--</br>--     构建结果 ： 详细结果见附件! file：【build-.txt】   </br>--</br>--    版本路径  : <a href=\""
						+ SysProperies.getValue("cl.report.share")
						+ "\"> "
						+ SysProperies.getValue("cl.report.share")
						+ "</a>(user/pwd=administrator/sunday) </br>--</br>"
						+ "--   访问地址 :  <a href=\""
						+ SysProperies.getValue("cl.web.url")
						+ "\" >"
						+ SysProperies.getValue("cl.web.url")
						+ "</a>(user/pwd=admin/admin) </br>-- --    --   END    ------</br>");
		/*
		MailNotify
				.sendSmtpEmail(
						"sunyanzheng@hyxell.com",
						"sunyanzheng@hyxell.com",
						"Sunday123",
						"smtp.hyxell.com",
						toMailers,
						"版本构建",
						"--    每日构建      --  time [ test]  --- </br>--</br>--     构建结果 ： 详细结果见附件! file：【stet】   </br>--</br>--    版本路径  : <a href=\""
								+ SysProperies.getValue("cl.report.share")
								+ "\"> "
								+ SysProperies.getValue("cl.report.share")
								+ "</a>(user/pwd=administrator/sunday) </br>--</br>"
								+ "--   访问地址 :  <a href=\""
								+ SysProperies.getValue("cl.web.url")
								+ "\" >"
								+ SysProperies.getValue("cl.web.url")
								+ "</a>(user/pwd=admin/admin) </br>-- --    --   END    ------</br>");*/

	}

	/**
	 * 
	 * test
	 * 
	 * @param i
	 *            int
	 */
	public static void test(int i) {
		// System.out.println("aaaa"+i);
	}

}
